package cn.lyq.card.ui.realname

import androidx.lifecycle.LiveData
import cn.lyq.card.base.SimpleVM
import cn.lyq.card.data.model.UploadInfo
import cn.lyq.card.data.src.Result
import cn.lyq.card.utils.RetrofitUtils
import java.io.File


class RealNameAuthVM : SimpleVM() {

    fun verifyRealName(
        name: String,
        idCode: String,
        bankCard: String,
        code: String,
        imgId: String,
        imgIdReverse: String
    ) = simpleEmit {
        repository.userService.verifyTrueName(name, idCode, bankCard, code, imgId, imgIdReverse)
    }

    fun upload(file: File): LiveData<Result<UploadInfo>> {
        val map = mapOf(Pair("type", "icon"))
        return simpleEmit {
            val body = RetrofitUtils.buildBody(map, arrayOf(file))
            repository.userService.upload(body)
        }
    }
}